package com.example.demo.dto.user.login;

import org.springframework.util.StringUtils;

public class ULoginDto {
    private Integer user_id;
    private String password;
    private Integer identity; // 0管理员；1教师；2学生；3家长

    public Integer getUser_id() {
        return user_id;
    }

    public void setUser_id(Integer user_id) {
        this.user_id = user_id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getIdentity() {
        return identity;
    }

    public void setIdentity(Integer identity) {
        this.identity = identity;
    }

    // 参数校验
    public String CheckOut(){
        if(this.identity == null){
            return "身份牌不得为空";
        }
        if(this.identity != 0 && this.identity != 1 && this.identity != 2 && this.identity != 3){
            return "身份牌填写有误";
        }
        if(this.user_id == null){
            return "个人id不得为空";
        }
        if(this.user_id < 1 || this.user_id > 100000 ){
            return "个人id有误";
        }
        if(!StringUtils.hasLength(this.password)){
            return "密码不得为空";
        }
        if(this.password.length() < 3 || this.password.length() >12){
            return "密码长度有误";
        }
        return "";
    }
}
